<template>
	<view class="content">
		<view>当前OM {{ uMsg.currnetOm || 0 }}</view>

		<view class="button-sp-area"><button button class="mini-btn" type="primary" size="mini" @click="showGame()">游戏</button></view>

		<view class="uni-padding-wrap uni-common-mt">
			<uni-list>
				<uni-list-item
					v-for="(item, index) in getGameList"
					:key="index"
					:title="item.title"
					:thumb="item.thumb"
					:note="item.note"
					@click="itemClick(item.type, index)"
				></uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations, mapGetters } from 'vuex';

import uniList from '@/components/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
import swiPer from '../component/swiper/swi-per.vue';

export default {
	computed: {
		...mapState(['forcedLogin', 'hasLogin']),
		...mapGetters({
			uMsg: 'userSotre/getUmsg',
			getGameList: 'gameSotre/getGameList'
		})
	},

	components: {
		swiPer,
		uniList,
		uniListItem
	},

	data() {
		return {
			bViewStyle: {
				width: 50
			},

			lGame: [
				{
					title: '1',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=922472845,1139880885&fm=27&gp=0.jpg',
					note: '1112',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				},
				{
					title: '2',
					thumb: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1271024482,335557211&fm=27&gp=0.jpg',
					note: '3332',
					type: '1'
				},
				{
					title: '3',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1863856199,3899042121&fm=27&gp=0.jpg',
					note: '2222',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				},
				{
					title: '4',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1941083878,3999612106&fm=27&gp=0.jpg',
					note: '4442',
					type: '1'
				},
				{
					title: '5',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=922472845,1139880885&fm=27&gp=0.jpg',
					note: '1112',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				},
				{
					title: '6',
					thumb: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1271024482,335557211&fm=27&gp=0.jpg',
					note: '3332',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				},
				{
					title: '7',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1863856199,3899042121&fm=27&gp=0.jpg',
					note: '2222',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				},
				{
					title: '8',
					thumb: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1941083878,3999612106&fm=27&gp=0.jpg',
					note: '4442',
					type: '1',
					appId: 'wxc24d1aa4b8eaa9a1'
				}
			]
		};
	},

	created() {
		this.updateUpGameList();
	},

	methods: {
		...mapMutations(['updateList']),

		...mapMutations({
			updateGameList: 'gameSotre/updateGameList'
		}),

		showGame() {
			this.updateUpGameList();
		},

		updateUpGameList() {
			this.omHttp.verificationLogin(
				{},
				function() {
					this.updateGameList(this.lGame);
				}.apply(this)
			);
		},

		itemClick(type, index) {
			let sData = this.getGameList[index];
			if (sData.appId) {
				this.weixin.toMiniGame(sData.appId);
			} else {
				sData = JSON.stringify(sData);
				sData = encodeURIComponent(sData);
				if (type === this.commonOm.listType.game) {
					this.commonOm.navigateTo({
						url: '../show/show-game?data=' + sData
					});
				} else if (type === this.commonOm.listType.shop) {
					this.commonOm.navigateTo({
						url: '../show/show-shop?data=' + sData
					});
				}
			}
		}
	}
};
</script>

<style>
.hello {
	display: flex;
	flex: 1;
	flex-direction: column;
}

.title {
	color: #8f8f94;
	margin-top: 50upx;
}

.ul {
	font-size: 30upx;
	color: #8f8f94;
	margin-top: 50upx;
}

.ul > view {
	line-height: 50upx;
}

.image {
	margin: 40upx 0;
	width: 200upx;
}

.test-img {
	background: #0faeff;
}

.view-item {
	width: 100%;
	height: 200upx;
	background: #0faeff;
}

.button-sp-area {
	margin: 0 auto;
}

.mini-btn {
	margin-left: 10upx;
	margin-right: 10upx;
	position: relative;
	/*偏移*/
	transform: translateY(10%);
}
</style>
